import { get } from 'lodash-es'
import { Country } from '../country/types'

export class State {
  id?: string
  country_id?: string
  country?: Country
  code?: string
  name?: string
  disabled?: boolean
  sequence?: number
  created_id?: string
  updated_id?: string
  created_at?: string
  updated_at?: string
  version?: number;
  [key: string]: any

  constructor(data?: State) {
    this.init(data)
  }
}

State.prototype.init = function init(data?: State) {
  this.id = get(data, 'id')
  this.country_id = get(data, 'country_id')
  this.country = get(data, 'country')
  this.code = get(data, 'code', '')
  this.name = get(data, 'name', '')
  this.disabled = get(data, 'disabled', false)
  this.sequence = get(data, 'sequence', 1)
  this.created_id = get(data, 'created_id')
  this.updated_id = get(data, 'updated_id')
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_id')
  this.version = get(data, 'version')
}
